package 晚间作业0319;

import java.util.ArrayList;
import java.util.List;

/**
 * #### 1.(简单)
 *
 * 描述公司员工信息:
 *
 * 公司中有职员4人,包括程序员2个,美工1个,项目经理1个.
 *
 * 程序员有姓名,工号,薪水,工作内容-编程
 *
 * 美工:姓名,工号,薪水,工作内容-画图
 *
 * 项目经理有姓名,工号,薪水,奖金
 *
 * 工作内容-管理员工.
 *
 * /*
 * 用到的技术点
 * 对象实例化
 * 继承
 * 重写
 * 多态
 * final
 * Object
 * 抽象类
 * 构造方法在继承中的使用
 * super
 * this
 *  */
public class Doc_Cus1 {

    public static void main(String[] args) {
        EmployeeManageSystem manageSystem = EmployeeManageSystem.getInstance();
        manageSystem.addEmployee(new Programmer("ming", "00001", 18000));
        manageSystem.addEmployee(new Programmer("ning", "00002", 17000));
        manageSystem.addEmployee(new UI("tian", "00003", 8000));
        manageSystem.addEmployee(new PM("wuji", "00004", 11000, 5000));
        manageSystem.printEmployeeInfo();
    }

    public static final class EmployeeManageSystem {
        private static final List<Employee> employees = new ArrayList<>();
        public static final EmployeeManageSystem INSTANCE = new EmployeeManageSystem();
        public static EmployeeManageSystem getInstance() { return INSTANCE; }
        private EmployeeManageSystem(){}

        public void addEmployee(Employee employee) {
            employees.add(employee);
        }

        public void printEmployeeInfo() {
            for (Employee employee : employees) {
                System.out.println(employee.toString());
            }
        }
    }

    private static abstract class Employee {
        protected String eName;
        protected String eNumber;
        protected String job;
        protected double salary;
        public abstract String jobContent();

        public Employee(String eName, String eNumber, String job, double salary) {
            this.eName = eName;
            this.eNumber = eNumber;
            this.job = job;
            this.salary = salary;
        }

        @Override
        public String toString() {
            return eNumber + "\t" + eName + "\t" + job + "\t" + salary + "\t" + jobContent();
        }
    }

    public static class Programmer extends Employee {
        public Programmer(String eName, String eNumber, double salary) {
            super(eName, eNumber, "程序员", salary);
        }

        @Override
        public String jobContent() {
            return "编程";
        }
    }

    public static class UI extends Employee {

        public UI(String eName, String eNumber, double salary) {
            super(eName, eNumber, "美工", salary);
        }
        @Override
        public String jobContent() {
            return "画图";
        }
    }

    public static class PM extends Employee {
        private double bonus;
        public PM(String eName, String eNumber, double salary, double bonus) {
            super(eName, eNumber, "项目经理", salary);
            this.bonus = bonus;
        }
        @Override
        public String jobContent() {
            return "管理员工";
        }

        @Override
        public String toString() {
            return eNumber + "\t" + eName + "\t" + job + "\t" + salary + "\t" + bonus + "\t" + jobContent();
        }
    }

}
